-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #824
base: master
Are you sure you want to change the base?
Solution #824
Conversation
app/main.py
Outdated
for index1 in range(len(person_list)): | ||
if "wife" in people[index1]: | ||
if people[index1]["wife"] is not None: | ||
for index2 in range(len(people)): | ||
if people[index1]["wife"] == people[index2]["name"]: | ||
person_list[index1].wife = person_list[index2] | ||
|
||
elif "husband" in people[index1]: | ||
if people[index1]["husband"] is not None: | ||
for index2 in range(len(people)): | ||
if people[index1]["husband"] == people[index2]["name"]: | ||
person_list[index1].husband = person_list[index2] | ||
return person_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So hard realization...... First of all why do you iterate through index? Also, why do you use loop into loop?
You have Person.people dict use it and only one loop here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the first loop to add attributes to each person and the second to find husband/wife for him, I don't know how to make it by one loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use index because it is the same in the dict and in the list or person and it is easy to iterate so -__-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont answer I got you )
…е проходило по довжині flake8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
No description provided.